package com.nw.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.nw.redis.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: Administrator
 * @Date: 2018/8/10 0010 14:36
 * @Description:
 */
@RestController
@RequestMapping("redis")
public class RedisController {
    @Autowired
    RedisService redisService;
    @RequestMapping("/get")
    @ResponseBody
    public String getRedis(String key){
        String strVal = redisService.getInstance().get(key);
        return strVal;
    }
    @RequestMapping("/getObject")
    @ResponseBody
    public JSONObject getRedisObject(String key){
        JSONObject jsonObject = JSON.parseObject(redisService.getInstance().get(key));
        return jsonObject;
    }
    @RequestMapping("/getCount")
    @ResponseBody
    public long getCount(){
        long count = redisService.getInstance().dbSize();
        return count;
    }
}
